<?php
namespace app\admin\controller;

use app\admin\model\Feedback as FeedbackModel;
use think\Request;
use think\Exception;

class Feedback extends Common
{
    // 企业信息管理
    public function index()
    {
        $data = [];
        //搜索
        $telephone = input('post.telephone');
        $data['telephone'] = $telephone;
        $company_name = input('post.company_name');
        $data['company_name'] = $company_name;
        //页码
        $pageNum = 1;
        if (is_numeric(input('post.pageNum'))) {
            $pageNum = input('post.pageNum');
        }
        $data['pageNum'] = $pageNum;
        //每页数量
        $numPerPage = config('num_per_page');
        $data['numPerPage'] = $numPerPage;
        $model = new FeedbackModel;
        //列表数据
        $list = $model->getList($pageNum, $numPerPage);
        $data['list'] = $list;
        //数据总数
        $count = $model->getCount();
        $data['count'] = $count;
        return view('', $data);
    }

    // 详情
    public function detail()
    {
        $id = input('get.id');
        $info = FeedbackModel::detail($id);
        if($info['look'] == 1){
            $info['look'] = '否';
        }else{
            $info['look'] = '是';
        }

        if(!empty($info['images'])){
            $info['images'] = explode(',',$info['images']);
            foreach ($info['images'] as $key => $item) {
                $info['images'][$key] = str_replace('\\','/',Request::instance()->domain() . DS . 'upload' . DS . 'api' . DS . 'image' . DS . $item);
            }
        }else{
            $info['images'] = [];
        }
        $data['info'] = $info;
        return view('', $data);
    }

}